package vn.demand.dragon
{
	import org.puremvc.as3.interfaces.IFacade;
	import org.puremvc.as3.patterns.facade.Facade;
	
	import vn.demand.dragon.controller.CloseProjectTaskLogsPanelCommand;
	import vn.demand.dragon.controller.CloseProjectTasksPanelCommand;
	import vn.demand.dragon.controller.CloseReferenceOperatorListCommand;
	import vn.demand.dragon.controller.CloseSuppliersListCommand;
	import vn.demand.dragon.controller.OpenCustomerListCommand;
	import vn.demand.dragon.controller.OpenProjectTaskLogsCommand;
	import vn.demand.dragon.controller.OpenProjectTasksCommand;
	import vn.demand.dragon.controller.OpenReferenceOperatorListCommand;
	import vn.demand.dragon.controller.OpenSupplierFormCommand;
	import vn.demand.dragon.controller.OpenSupplierListCommand;
	import vn.demand.dragon.controller.OperatorStartupCommand;
	import vn.demand.dragon.controller.RemoveSupplierCommand;
	import vn.demand.dragon.controller.RequestLoginCommand;
	import vn.demand.dragon.controller.RequestLogoutCommand;
	import vn.demand.dragon.controller.SupplierRemovedCommand;
	
	public class OperatorApplicationFacade extends Facade implements IFacade
	{
		
		/**
		 * Start the application
		 */
		 public function startup(app:Object):void
		 {
		 	sendNotification( CommonCommand.REQUEST_LOGIN, app );
		 }
		 
		/**
		 * Singleton ApplicationFacade Factory Method
		 */
		public static function getInstance() : OperatorApplicationFacade {
			if ( instance == null ) instance = new OperatorApplicationFacade( );
			return instance as OperatorApplicationFacade;
		}
		
		override protected function initializeController( ) : void 
		{
			super.initializeController();
			registerCommand( CommonCommand.REQUEST_LOGIN, RequestLoginCommand);
			registerCommand( CommonCommand.LOGIN_SUCCESSFUL, OperatorStartupCommand);
			registerCommand( FFIAApplicationFacade.OPEN_REFERENCES_LIST, OpenReferenceOperatorListCommand);
			registerCommand( FFIAApplicationFacade.CLOSE_REFERENCES_LIST, CloseReferenceOperatorListCommand);
			
			registerCommand( CommonCommand.OPEN_COSTOMERS_LIST, OpenCustomerListCommand);
			registerCommand( CommonCommand.OPEN_SUPPLIERS_LIST, OpenSupplierListCommand);
			registerCommand( CommonCommand.CLOSE_SUPPLIERS_LIST, CloseSuppliersListCommand);
			registerCommand( CommonCommand.EDIT_SUPPLIER, OpenSupplierFormCommand );
			registerCommand( CommonCommand.ADD_SUPPLIER, OpenSupplierFormCommand);
			registerCommand( CommonCommand.REMOVE_SUPPLIER, RemoveSupplierCommand);
			registerCommand( CommonCommand.SUPPLIER_REMOVED, SupplierRemovedCommand);
			registerCommand( CommonCommand.REQUEST_LOGOUT, RequestLogoutCommand);
			
			registerCommand( CommonCommand.OPEN_PROJECT_TASKS_PANEL, OpenProjectTasksCommand);
			registerCommand( CommonCommand.CLOSE_FINISH_PROJECT_TASKS_PANEL, CloseProjectTasksPanelCommand);
			
			registerCommand( CommonCommand.OPEN_PROJECT_TASK_LOGS_PANEL, OpenProjectTaskLogsCommand);
			registerCommand( CommonCommand.CLOSE_FINISH_PROJECT_TASK_LOGS_PANEL, CloseProjectTaskLogsPanelCommand);
		}
		
	}
}